from sqlalchemy import Column, Integer, String, DateTime, func
from database import Base

class Certificate(Base):
    __tablename__ = "t_certificates"

    id = Column(Integer, primary_key=True, index=True, autoincrement=True)
    domain = Column(String(255), unique=True, nullable=False, comment="域名")
    cert = Column(String, nullable=True, comment="证书内容")
    fullchain = Column(String, nullable=False, comment="Fullchain 证书内容")
    privkey = Column(String, nullable=False, comment="私钥内容")
    requested_at = Column(DateTime(timezone=True), nullable=True, comment="证书申请时间")
    created_at = Column(DateTime(timezone=True), server_default=func.now(), comment="记录创建时间")
    updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now(), comment="记录更新时间")
